import { defineStore } from 'pinia'
// 引入接口
import { getCategoryAPI } from '@/apis/layout/index'
import { ref } from 'vue'

// 导航列表的数据管理
export const useCategoryStore = defineStore('category', () => {
  // state 导航列表数据
  let categoryList = ref<any>([])
  // action 获取导航数据的方法
  const getCategory = async () => {
    let res: any = await getCategoryAPI()
    if (res.code === '1') {
      categoryList.value = res.result
    }
  }

  return {
    categoryList,
    getCategory,
  }
})
